/*
 * Criteria.java
 *
 * Created on August 12, 2007, 1:05 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package tcc.dao;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Diego
 */
public class Criteria {
    
    private List<String> criteria = new LinkedList<String>();
    /** Creates a new instance of Criteria */
    public Criteria() {
        
    }
    
    public void addCriterion(String criterion){
        criteria.add(criterion);
    }
    
    public void removeCriterion(String criterion){
        criteria.remove(criterion);
    }
    
    public String listCriteria(){
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (String elem : criteria){
            sb.append('\n');
            if(first){
                sb.append("where ");
                first = false;
            }else{
                sb.append("and ");
            }
            sb.append(elem);
        }
        return sb.toString();
    }
    
}
